import { request } from "@/utils/request";
let userinfo = JSON.parse(sessionStorage.getItem('userInfo'))
let userId = ''
let organizationId = 0;
if (userinfo) {
    organizationId = userinfo.tenantId
    userId = userinfo.loginName
}
export const api = {
  getProjectRMEntityList:"/project/Windchill/servlet/rest/hzero/pmgt/rm/getProjectRMEntityList",
  getProjectRMEntity:"/project/Windchill/servlet/rest/hzero/pmgt/rm/getProjectRMEntity",
  checkRmEntity:"/project/Windchill/servlet/rest/hzero/pmgt/rm/checkRmEntityAssociatedProjectsForMores",
  getPPMSubPlan:"/project/Windchill/servlet/rest/hzero/pmgt/rm/getPPMSubPlan",
  getPPMSubPlanRmEntity:"/project/Windchill/servlet/rest/hzero/pmgt/rm/getPPMSubPlanAssociatedRmEntity",
  // getRmTaskAssociatedRmEntity:"/project/Windchill/servlet/rest/hzero/pmgt/rm/getRmTaskAssociatedRmEntity",
  saveRmAssociatedProjectsForMores:"/project/Windchill/servlet/rest/hzero/pmgt/rm/saveRmAssociatedProjectsForMores",
  getVersionHistory:"/project/Windchill/servlet/rest/hzero/pdm/core/getVersionHistory",
  getRmEntityAssociatedMaterial:"/project/Windchill/servlet/rest/hzero/pmgt/rm/getRmEntityAssociatedMaterial",
  getFlowRmEntityAssociatedMaterial:"/project/Windchill/servlet/rest/hzero/pmgt/rm/getFlowRmEntityAssociatedMaterial",
  getRmEntityAssociated:"/project/Windchill/servlet/rest/hzero/pmgt/rm/getRmEntityAssociated",
  checkRmEntityAssociatedProjectsForMores:"/project/Windchill/servlet/rest/hzero/pmgt/rm/checkRmEntityAssociatedProjectsForMores",
  getProjectsForMores:"/project/Windchill/servlet/rest/hzero/pmgt/rm/getProjectsForMores",
  checkRmEntityRemoveProjectsForMores:"/project/Windchill/servlet/rest/hzero/pmgt/rm/checkRmEntityRemoveProjectsForMores",
  removeAssociated:"/project/Windchill/servlet/rest/hzero/pmgt/rm/removeAssociated",
  getPPMSubPlanAssociatedRmEntity:"/project/Windchill/servlet/rest/hzero/pmgt/rm/getPPMSubPlanAssociatedRmEntity",
  getRmTask:"/project/Windchill/servlet/rest/hzero/pmgt/rm/getRmTask"
};
// 获取需求(RM)  列表
export function getProjectRMEntityList(parameter) {
  return request({
    url: api.getProjectRMEntityList,
    method: 'post',
    data: parameter
  })
}
// 获取需求(RM) 详情
export function getProjectRMEntity(parameter) {
  return request({
    url: api.getProjectRMEntity,
    method: 'post',
    data: parameter
  })
}
// 获取(搜索)添加关联弹框的表格接口
export function getProjectsForMores(parameter) {
  return request({
    url: api.getProjectsForMores,
    method: 'post',
    data: parameter
  })
}
// 判断选中的需求是否可以 '关联' 项目与 变更
export function checkRmEntityAssociatedProjectsForMores(parameter) {
  return request({
    url: api.checkRmEntityAssociatedProjectsForMores,
    method: 'post',
    data: parameter
  })
}
// 判断选中的需求是否可以 '移除' 项目与 变更
export function checkRmEntityRemoveProjectsForMores(parameter) {
  return request({
    url: api.checkRmEntityRemoveProjectsForMores,
    method: 'post',
    data: parameter
  })
}
// 移除关联按钮的接口
export function removeAssociated(parameter) {
  return request({
    url: api.removeAssociated,
    method: 'post',
    data: parameter
  })
}
// 获取子规划的需求RM表格
export function getPPMSubPlanAssociatedRmEntity(parameter) {
  return request({
    url: api.getPPMSubPlanAssociatedRmEntity,
    method: 'post',
    data: parameter
  })
}
// 获取需求任务单流程详情
export function getRmTask(parameter) {
  return request({
    url: api.getRmTask,
    method: 'post',
    data: parameter
  })
}
// 获取需求(RM)详情的物料清单
export function getRmEntityAssociatedMaterial(parameter) {
  return request({
    url: api.getRmEntityAssociatedMaterial,
    method: 'post',
    data: parameter
  })
}
// 获取需求(RM)审批流程的物料清单（需求流程里面的物料清单）
export function getFlowRmEntityAssociatedMaterial(parameter) {
  return request({
    url: api.getFlowRmEntityAssociatedMaterial,
    method: 'post',
    data: parameter
  })
}
// 获取需求(RM)详情的历史版本（历史记录）
export function getVersionHistory(parameter) {
  return request({
    url: api.getVersionHistory,
    method: 'post',
    data: parameter
  })
}
// 需求是否能关联项目与变更
export function checkRmEntity(parameter) {
  return request({
    url: api.checkRmEntity,
    method: 'post',
    data: parameter
  })
}
// PPM子规划详情
export function getPPMSubPlan(parameter) {
  return request({
    url: api.getPPMSubPlan,
    method: 'post',
    data: parameter
  })
}
// PPM子规划关联的需求
export function getPPMSubPlanRmEntity(parameter) {
  return request({
    url: api.getPPMSubPlan,
    method: 'post',
    data: parameter
  })
}
// 需求任务单流程中的 (需求(RM)表格)  
export function getRmEntityAssociated(parameter) {
  return request({
    url: api.getRmEntityAssociated,
    method: 'post',
    data: parameter
  })
}
// export function getRmTaskAssociatedRmEntity(parameter) {
//   return request({
//     url: api.getRmTaskAssociatedRmEntity,
//     method: 'post',
//     data: parameter
//   })
// }
// 需求关联项目与变更 （添加关联弹框确定按钮调的接口）
export function saveRmAssociatedProjectsForMores(parameter) {
  return request({
    url: api.saveRmAssociatedProjectsForMores,
    method: 'post',
    data: parameter
  })
}